package top.mengchaob.fileserver.netty.jpa;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import top.mengchaob.deploy.table.HostDo;
import top.mengchaob.fileserver.netty.table.FileDo;
import top.mengchaob.fileserver.netty.table.FileLBDo;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @title：
 * @author: mengchaob
 * @date: 2021年05月12日 14:42
 * @description:
 */
public interface FileRepository  extends JpaRepository<FileDo, String> {
    @Query("select f FROM FileDo f WHERE f.lbCode like CONCAT(?1,'%')")
    public List<FileDo> queryByLbcode(@Param("lb_code")String lb_code);
    @Modifying
    @Query("DELETE FROM FileDo f WHERE f.lbCode like CONCAT(?1,'%')")
    public int delByLbcode(@Param("lb_code")String lb_code);
    @Modifying
    @Query("DELETE FROM FileDo u WHERE u.fileId in ?1")
    @Transactional
    public int deleteByIds(List<String> fileIds);
}
